<script setup>
defineProps({
  message: {
    type: String,
    default: ''
  },
  isUser: {
    type: Boolean,
    default: false
  },
  html: {
    type: String,
    default: ''
  }
})
</script>

<template>
  <div :class="['message', isUser ? 'user-message' : 'bot-message']">
    <div
        v-if="html"
        class="message-content markdown-content"
        v-html="html"
    ></div>
    <div v-else class="message-content">{{ message }}</div>
  </div>
</template>

<style scoped>
.message {
  max-width: 80%;
  padding: 8px 16px;
  border-radius: 18px;
  margin-bottom: 4px;
}

.user-message {
  align-self: flex-end;
  background-color: #4CAF50;
  color: white;
}

.bot-message {
  align-self: flex-start;
  background-color: #f1f1f1;
  color: #333;
}

.message-content {
  word-wrap: break-word;
}

.markdown-content {
  text-align: left;
}

.markdown-content :deep(pre) {
  background-color: #f5f5f5;
  padding: 10px;
  border-radius: 4px;
  overflow-x: auto;
}

.markdown-content :deep(code) {
  font-family: monospace;
}

.markdown-content :deep(blockquote) {
  border-left: 4px solid #ddd;
  padding-left: 16px;
  color: #666;
}
</style>